package com.example.testrecycleviewdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    private RecyclerView mRecycleView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mRecycleView = (RecyclerView) findViewById(R.id.main_recyclerview);

        // 第1步: 设置布局管理器
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//        GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
//        layoutManager.setOrientation(GridLayoutManager.VERTICAL);
        mRecycleView.setLayoutManager(layoutManager);

        // 第2步: 设置适配器
        mRecycleView.setAdapter(new MyAdapter(getApplicationContext()));

        // RecyclerView相关的类:
        // 布局管理器:XXXLayoutManager: 显示风格:列表,表格,瀑布流
        // 数据适配器Adapter
        // ViewHolder
    }
}
